var totalPage = 0;
var totalCnt = 0;
var equipmentPowerTypeData = [];

$(document).ready(function() {
	showLoading();
    $('title', parent.document).html($('title').text());
    setBaseUrl();
    createTableHead("equipmentPowerTypeThead", equipmentPowerTypeTable, search);
    scrollTableSuspend("scrollBody", "equipmentPowerTypeTable", "equipmentPowerTypeTable1", "equipmentPowerTypeThead", "scrollHeight");
    search();
    setTimeout(hideLoading, 500);
})

function searchEquipmentPowerType(data) {
	totalPage = data && data.totalPage || 0;
	totalCnt = data && data.totalCnt || 0;
	equipmentPowerTypeData = data && data.equipmentTypeList || [];
	createTableBody("equipmentPowerTypeTbody", equipmentPowerTypeTable, equipmentPowerTypeData);
}
function search(){
	$ajax('searchEquipmentPowerType', 'searchEquipmentPowerType', searchEquipmentPowerType);
}
function chkBefore(index, chkFlag){
	var checkbox =document.getElementsByName("chk"); 
	for(var i=0; i<checkbox.length; i++){
		checkbox[i].checked = false; 
	}
	checkbox[index].checked = true; 
	if(chkFlag == "update"){
		update(index);
	}else if(chkFlag == "delete"){
		del();
	}
}
//添加
function save() {
	window.parent.skipSecondMenu('chargingEquipment/equipmentPowerTypeSave', 'equipmentPowerType', 'equipmentPage');
}
//修改
function update(index) {
	window.parent.detalisSkip('chargingEquipment/equipmentPowerTypeUpdate', index, $("#currentPage").val());
	$("#parentSkipMenu", parent.document).val("equipmentPage");
	$("#detailID", parent.document).val(equipmentPowerTypeData[index].equipmentPowerType);
}
function confirm(){
	return checkForm("saveForm", equipmentPowerTypeTable);
}
function getUrl(){
	return 'deleteEquipmentPowerType';
}
function getData(){
	return {equipmentPowerTypeList: getCheckDataList(equipmentPowerTypeData, "equipmentPowerType")};
}
function sure(data){
    var result = data && data.result;
    if (result == "Success") {
		showMessge(messageContent["Delete.Success"]);
	} else if (result == "NotFound") {
		showMessge(messageContent["Delete.NotFound"]);
	} else {
		showMessge(messageContent["Delete.Error"]);
	}
    $ajax('searchEquipmentPowerType', 'searchEquipmentPowerType', searchEquipmentPowerType);
}